<?php
	$fields_arr = array(
		'information_ad_place_title'=>'广告位',
		'title'=>'标题',
		'content'=>'内容',
		'summary'=>'描述',
		'link'=>'广告链接',
		'target'=>'打开方式',
		'addtime'=>'投放开始时间',
		'remaining_time'=>'剩余天数',
		'endtime'=>'投放结束时间',
		'admin_manager_username'=>'操作人',
		'operation'=>'操作',
	);
	if(!$custom_field_arr){
		$custom_field_arr = array_flip($fields_arr);
	}
	$fields_arr_new = array_merge($custom_field_arr,array_flip($fields_arr));
	$fields_arr_new = array_unique($fields_arr_new);
?>
{include app:admin.inc.header}
<!--tmpl-resource-->
{include app:admin.inc.top}
<link rel="stylesheet" href="/res/js/framework/nestable/nestable.css">
<div class="container-fluid content-body">
	<div class="main">
		<!-- left side start-->

		<section class="left-section">
			<dl id="leftNav" data-type="message">
				<dt><i class="glyphicon glyphicon-plus"></i> 信息管理</dt>
				{if in_case_array('admin/notice',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/notice/index}">公告管理</a></dd>
				{/if}
				{if in_case_array('admin/information',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/information/index}">资讯管理</a></dd>
				{/if}
				{if in_case_array('admin/singlepage',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/singlepage/index}">单页管理</a></dd>
				{/if}
				{if in_case_array('admin/brand',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/brand/index}">特约品牌</a></dd>
				{/if}
				{if in_case_array('admin/adPlace',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/adPlace/index}">广告位管理</a></dd>
				{/if}
				{if in_case_array('admin/ad',$priv) || empty($priv)}
				<dd><a class="mb active" href="{url /admin/ad/index}">广告管理</a></dd>
				{/if}
			</dl>
		</section>

		<!-- left side end-->


		<!-- main content start-->
		<section class="right-section" id="right-section">
			{include admin.inc.bread}
			<h2 class="header">广告列表</h2>
			<!-- start of inner-frame -->
			<div class="inner-iframe">

				<div class="inner-container">
					<form class="form-inline search-form" role="form"  id="J_List_Form">
						<nav class="inline-form">
							<a class="btnlg mb fl" href="{$add_url}"><i class="css-add"></i>添加广告</a>
							<div class="row">
							<div class="r">
								<div class="form-group">
									<div class="input-group">
										<div class="input-group-addon">
											广告位置
										</div>
										<div class="css-select">
											<div class="chosen">
												<span></span>
												<i class="angle-down"></i>
												<input type="hidden" name="s_ad_place_key" value="{$s_ad_place_key}">
											</div>
											<ul>
												<li data-value="0">全部</li>
												{loop $adPlaces $adP}
												<li data-value="{$adP.key}">{$adP.title}</li>
												{/loop}
											</ul>
										</div>
									</div>
								</div>
								<div class="form-group">
									<div class="input-group">
										<div class="input-group-addon">
											标题
										</div>
										<input type="text" class="form-control input-sm" maxlength="50" placeholder="标题" name="s_title" value="{$s_title}">
									</div>
								</div>
								<div class="form-group">
									<div class="input-group">
										<div class="input-group-addon">
											投放开始时间
										</div>
										<input style="width:100px;" class="form-control form-control-inline input-sm mdate"  size="16" type="text"
											   name="s_s_addtime" value="{$s_s_addtime}"
											   placeholder="开始时间" />

										<div class="input-group-addon">
											-
										</div>
										<input style="width:100px;" class="form-control form-control-inline input-sm mdate"  size="16" type="text"
											   name="s_e_addtime" value="{$s_e_addtime}"
											   placeholder="结束时间" />
									</div>
								</div>
								<div class="form-group">
									<div class="input-group">
										<div class="input-group-addon">
											投放结束时间
										</div>
										<input style="width:100px;" class="form-control form-control-inline input-sm mdate"  size="16" type="text"
											   name="s_s_endtime" value="{$s_s_endtime}"
											   placeholder="开始时间" />

										<div class="input-group-addon">
											-
										</div>
										<input style="width:100px;" class="form-control form-control-inline input-sm mdate"  size="16" type="text"
											   name="s_e_endtime" value="{$s_e_endtime}"
											   placeholder="结束时间" />
									</div>
								</div>

								<input type="hidden" name="order" value="{$order}">
								<button type="submit" class="btnlg mb">搜索</button>
								<input type="hidden" name="pagesize" value="{$pagesize}" >
								<button type="button" class="btnlg mb" id="J_Export_btn">导出Excel</button>
								<button type="button" class="btnlg mb" id="defined">配置列表项</button>
							</div>
							</div>
						</nav>

						<div class="table-responsive">
							<table id="J_ListTable" class="table  table-hover  table-striped">
								<!--tmpl-listtable-->

								<!-- listblock -->
								<thead>
									<tr>
										<th width="20">
											<label class="css-checkbox">
												<input type="checkbox" class="check-all">
												<span></span>
											</label>
										</th>
										{loop $custom_field_arr $k $v}
										<th>{$fields_arr[$v]}</th>
										{/loop}
									</tr>
								</thead>
								<tbody>
								{if empty($items)}
								<tr>
									<td style="text-align:center;" colspan="9" class="empty-table-td">{$emptyRecord}</td>
								</tr>
								{/if}
								{loop $items $value}
								<tr>
									<td>
										<label class="css-checkbox">
											<input type="checkbox"  name="ids[]" value="{$value[id]}">
											<span></span>
										</label>
									</td>
									{loop $custom_field_arr $v}
									{if $v=='title'}
									<td>{cut $value[title] 20}</td>
									{else}
									{if $v=='content'}
									<td><img src="{$value[content]}" width="100px" /></td>
									{else}
									{if $v=='summary'}
									<td>{cut $value[summary] 20}</td>
									{else}
									{if $v=='link'}
									<td>{cut $value[link] 20}</td>
									{else}
									{if $v=='target'}
									<td>{if $value[target] == 0}当前窗口{else}新窗口{/if}</td>
									{else}
									{if $v=='addtime'}
									<td>{expr date("Y-m-d",strtotime($value[addtime]))}</td>
									{else}
									{if $v=='endtime'}
									<td>{if intval($value[endtime]) ==0 }永久{else}{expr date("Y-m-d",strtotime($value[endtime]))}{/if} </td>
									{else}
									{if $v=='operation'}
									<td>
										{if in_array('admin/ad/edit',$priv) || empty($priv)}
										<a href="{$edit_url}?id={$value[id]}" class="btnsm-primary">编辑</a>
										{/if}
										{if in_array('admin/ad/delete',$priv) || empty($priv)}
										<a href="{$delete_url}?id={$value[id]}" class="btnsm-danger item-remove">删除</a>
										{/if}
									</td>
									{else}
									<td>{$value[$v]}</td>
									{/if}
									{/if}
									{/if}
									{/if}
									{/if}
									{/if}
									{/if}
									{/if}
									{/loop}
								</tr>
								{/loop}
								</tbody>
							</table>
						</div>
					</form>
					<div class="btn-group dropup" data-act="operateAll">
						<button type="button" class="btnlg mb js-deletes" disabled>批量删除</button>
					</div>
					<div class="text-right">
						{$pagemenu}
					</div>

				</div>
			</div>
		</section>
	</div>
</div>

<!--footer section start-->
{include admin.inc.footer}
<!--footer section end-->

<!--tmpl-script-->

<!-- template -->
<!--自定义start-->
<script id="defined_table" type="text/html">
	<div>
		<form id="defined_edit" class="form-horizontal">
			<input type="hidden" name="url" value="{$module}/{$action}/{$method}">
			<div class="de_title"><i></i>拖动改变顺序</div>
			<div class="cf">
				<div class="dd" id="nestable3">
					<ol class="dd-list">
						{loop $fields_arr_new $v}
						<li class="dd-item dd3-item" data-id="{$v}">
							<div class="dd-handle dd3-handle"></div><div class="dd3-content">
							<label class="css-checkbox">
								<input type="checkbox" {if in_array($v,$custom_field_arr)}checked="checked"{/if} name="field_arr[]" value="{$v}">
								<span>{$fields_arr[$v]}</span>
							</label>
						</div>
						</li>
						{/loop}
					</ol>
				</div>
			</div>
		</form>
	</div>
</script>
<!--自定义end-->

<script id="editpanel" type="text/html">
	<div>
		<form id="editpanel-form" class="form-horizontal">
			<div class="row">&nbsp</div>
			<!--tmpl-fieldlist-->

			<!-- input -->
			<div class="form-group">
				<label >广告位 </label>
				<input  dtype="" class="form-control" maxlength="{maxlength}" name="data[ad_place_id]" placeholder="广告位" required cname="广告位" value="{[ad_place_id]}" />
			</div>
			<p class="help-block"></p>
			
			<!-- input -->
			<div class="form-group">
				<label >标题 </label>
				<input  dtype="" class="form-control" maxlength="50" name="data[title]" placeholder="标题" required cname="标题" value="{[title]}" />
			</div>
			<p class="help-block"></p>
			
			<!-- textarea -->
			<div class="form-group">
				<label>内容</label>
				<textarea class="form-control" maxlength="255" name="data[content]" placeholder="内容" required cname="内容">{[content]}</textarea>
			</div>
			<p class="help-block"></p>
			
			<!-- input -->
			<div class="form-group">
				<label >描述 </label>
				<input  dtype="" class="form-control" maxlength="255" name="data[summary]" placeholder="描述" required cname="描述" value="{[summary]}" />
			</div>
			<p class="help-block"></p>
			
			<!-- input -->
			<div class="form-group">
				<label >广告链接 </label>
				<input  dtype="" class="form-control" maxlength="255" name="data[link]" placeholder="广告链接" required cname="广告链接" value="{[link]}" />
			</div>
			<p class="help-block"></p>
			
			<!-- input -->
			<div class="form-group">
				<label >打开方式 </label>
				<input  dtype="" class="form-control" maxlength="{maxlength}" name="data[target]" placeholder="打开方式" required cname="打开方式" value="{[target]}" />
			</div>
			<p class="help-block"></p>
			

			<!--tmpl-assocfields-->
		</form>
	</div>
</script>

<!-- pagescript -->
<script type="text/javascript">
	seajs.use("admin/information_adindex",function (parameter){
		
		/**--tmpl-templatejavascript--**/
		
		<!--tmpl-templatejavascript-->
		parameter.detailUrl="{$detail_url}";
		parameter.deleteUrl="{$delete_url}";
		parameter.editUrl="{$do_edit_url}";
		parameter.upload_url="{$upload_url}";
		parameter.image_search_url="{$image_search_url}";
		parameter.image_list_url="{$image_list_url}";
		
		parameter.init();		
	});
</script>


<script id="assocpage" type="text/html">
<div class="text-right">
	<ul class="pagination blog-pagination">
		<li><a class="assoc-page" data-page="{[prev]}" href="javascript:void(0);">上一页</a></li> 
		{[loop pages page]}

		<li {[if curr == page]}class="active"{[/if]}><a class="assoc-page" data-page="{[page]}"  href="javascript:void(0)">{[page]}</a></li> 

		{[/loop]}
		<li><a class="assoc-page" href="javascript:void(0);" data-page="{[nexts]}">下一页</a></li> 
	</ul>	
</div>
</script>
</body>
</html>
